//
//  BMyContentView.swift
//  BMort_SwiftUI
//
//  Created by anscen on 2022/9/1.
//

import SwiftUI
private let about = "关于我们"
private let share = "分享"
private let good  = "好评"
private let set   = "设置"
struct BMyContentView: View {
    @State private var listData :[BMyModel] = []
    var body: some View {
        VStack {
            List(listData, id: \.self) { item in
                BMyCell(item: item)
            }.listStyle(.insetGrouped)
        }.onAppear {
            self.loadData()
        }
    }
    func loadData(){
        let item2 = BMyModel(title: about, icon: "icon_safe")
        let item3 = BMyModel(title: share, icon: "icon_historys")
        let item4 = BMyModel(title: good, icon: "icon_option")
        let item5 = BMyModel(title: set, icon: "icon_set")
        self.listData = [item2,item3,item4,item5]
    }
}
struct BMyCell :View {
    @State var item :BMyModel
    var body: some View{
        VStack.init {
            NavigationLink {
                switch item.title {
                case set:
                    Text("set")
                case about:
                    BAboutView()
                default:
                    Text("default")
                //break
                }
            } label: {
                HStack(alignment: .center, spacing: 0) {
                    Image(item.icon)
                    Text(item.title).padding().font(.system(size: 16)).foregroundColor(Color.appx000000())
                }
            }
        }
    }
}

